#include <iostream>

using namespace std;


typedef int (*MAX) (int, int);
typedef int (*MIN) (int, int);
typedef int (*CMP) (int, int);


int max(int, int);
int min(int, int);

int call(int, int, MAX);

typedef CMP (*pFunc) (int*, int*);

CMP callback(int*, int*);


int main()
{
    int num1, num2;
    cout << "input: " << endl;

    cin >> num1 >> num2;

    //int max_value = call(num1, num2, max);
    //cout << "max value: " << max_value << endl;
    pFunc pf = callback;
    CMP func = pf(&num1, &num2);
    int select_value = call(num1, num2, func);
    cout << "select value: " << select_value << endl;

    return 0;
}


int max(int a, int b)
{
    cout << "max func called" << endl;
    return a > b ? a : b;
}

int min(int a, int b)
{
    cout << "min func called" << endl;
    return a < b ? a : b;
}


int call(int x, int y, CMP func)
{
    return func(x, y);
}


CMP callback(int* x, int *y)
{
    if (*x > *y)
        return max;
    else
        return min;
}